﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<GlobalTask>" %>

<%
    if (ViewData["ThisTaskCompletion"] == null)
    {%>
    <td>N/R</td>
<%
        return;
    }%>

<%
    if (((bool)ViewData["ThisTaskCompletion"] && ViewData["CompletionDate"] == null) || ((bool)ViewData["ThisTaskCompletion"] && ViewData["CompletionDate"] != null && (DateTime)ViewData["CompletionDate"] <= Model.StartDate))
    {%>
     <td class="taskCompleted">
     <input type="hidden" globalTaskId="<%:Model.CheckPointId%>" studentId="<%:((Student) ViewData["Student"]).UserId%>" />
     <%
        if (ViewData["LoggedUser"] is SystemManager && ( ViewData["NextTaskCompletion"] == null || !(bool) ViewData["NextTaskCompletion"]))
        {%>             
            <%:Html.CheckBox("isCompleted", (bool) ViewData["ThisTaskCompletion"],
                                            new {@class = "CompletionSetter", onchange = "completionChanged(this)"})%>
     <%
        }%>
     </td>
<%
        return;
    }%>

    <%
        if (((bool)ViewData["ThisTaskCompletion"] && ViewData["CompletionDate"] == null) || ((bool)ViewData["ThisTaskCompletion"] && ViewData["CompletionDate"] != null && (DateTime)ViewData["CompletionDate"] > Model.StartDate))
    {%>
     <td class="taskCompletedNotInTime">
     <input type="hidden" globalTaskId="<%:Model.CheckPointId%>" studentId="<%:((Student) ViewData["Student"]).UserId%>" />
     <%
        if (ViewData["LoggedUser"] is SystemManager && ( ViewData["NextTaskCompletion"] == null || !(bool) ViewData["NextTaskCompletion"]))
        {%>             
            <%:Html.CheckBox("isCompleted", (bool) ViewData["ThisTaskCompletion"],
                                            new {@class = "CompletionSetter", onchange = "completionChanged(this)"})%>
     <%
        }%>
     </td>
<%
        return;
    }%>

<%
    if (!(bool) ViewData["ThisTaskCompletion"])
    {%>
    <td class="taskNotCompleted">   
    <input type="hidden" globalTaskId="<%:Model.CheckPointId%>" studentId="<%:((Student) ViewData["Student"]).UserId%>" />
    <%
        if (ViewData["LoggedUser"] is SystemManager && (ViewData["PreviousTaskCompletion"] == null || (bool)ViewData["PreviousTaskCompletion"]))
        {%> 
            <%:Html.CheckBox("isCompleted", (bool) ViewData["ThisTaskCompletion"],
                                            new {@class = "CompletionSetter", onchange = "completionChanged(this)"})%>
    <%
        }%>
    </td>
<%
    }%>

